package ControlLayer;
import ModelLayer.*;
import java.util.*;
import java.text.DateFormat;

/**
 * Write a description of class RentCtr here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class RentCtr
{
    private Rental rent;
    private RentalContainer rc;
    private DVDContainer DVDCollection;
    private ArrayList<Rental> rentList;
    private PersonContainer pc;
    private DVDSample sample;

    /**
     * Constructor for objects of class RentCtr
     */
    public RentCtr()
    {
//         DVDCollection = new DVDContainer();
    }
    
    public void rentDVDSample(int _dvdId, int _pId, int _id, String _deliveryDate)
    {
        try
        {
            DvD d = DVDCollection.findDVD(_dvdId);
            Person p = pc.findPerson(_pId);
            String toDay = DateFormat.getInstance().format(new Date());
            rent = new Rental(_id, toDay.substring(0, 8), _deliveryDate, d, p);
            rc.addRent(rent);
        }
        catch(Exception e)
        {
            System.out.println("There was an error.");
        }
    }
    public void deliverRent(int _id)
    {
        try
        {
            rc.deliverRent(_id);
        }
        catch(Exception e)
        {
            System.out.println("There was an error.");
        }
    }
    public Rental findRent(int _id)
    {
        try
        {
            return rc.findRent(_id);
        }
        catch(Exception e)
        {
            return null;
        }
    }
}
